///<reference path="../../../core/mengdao/api/mvc/command/BaseCommand.ts"/>
/**
 * Created by PengWei on 2018/7/27.
 */
namespace game {
    import BaseCommand = mengdao.BaseCommand;
    import Event = egret.Event;

    export class StageResizeCommand extends BaseCommand {
        public execute(data: any): void {
            let stage = this._context.stage;
            stage.addEventListener(Event.RESIZE, this.onResize, this);

            Config.STAGE_WIDTH = this._context.stage.stageWidth;
            Config.STAGE_HEIGHT = this._context.stage.stageHeight;
        }

        private onResize(e: Event): void {
            Config.STAGE_WIDTH = this._context.stage.stageWidth;
            Config.STAGE_HEIGHT = this._context.stage.stageHeight;
            this._context.dispatchEventWith(GameEvent.RESIZE);
        }
    }
}